package com.woniuxy.listener;

import com.woniuxy.service.FoodService;
import org.redisson.api.RBloomFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import java.nio.file.FileStore;

/**
 * @BelongsProject: pigTrotterStore
 * @BelongsPackage: com.woniuxy.listener
 * @Author: Quan
 * @Date: 2025/3/13 8:35
 */
@Component
public class StartListener implements ApplicationListener<ApplicationReadyEvent> {
	@Autowired
	RBloomFilter<String> bloomFilter;

	@Autowired
	private FoodService foodService;

	@Override
	public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
		foodService.queryIds()
				.stream()
				.map(String::valueOf)
				.forEach(bloomFilter::add);
	}
}
